package Week1;
import java.util.*;

public class Day2 {
}


//牛客:BC64 牛牛的快递
class Main3 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double x = in.nextDouble();
        String s = in.next();
        char ch = s.charAt(0);
        int pricer = 0;
        if(x <= 1){
            pricer = 20;
        }else{
            //pricer = 20 + (int)(x-0.1);
            pricer = 20 + (int)Math.ceil(x-1);
        }
        if(ch == 'y'){
            System.out.println(pricer+5);
        }else{
            System.out.println(pricer);
        }
    }
}

//牛客:DP4 最小花费爬楼梯
class Main4 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] cost = new int[n];
        int[] dp = new int[n + 1];
        for (int i = 0; i < n; i++) {
            cost[i] = in.nextInt();
        }
        if (n == 1){
            System.out.println(114514);
        }else {
            for (int i = 2; i <= n; i++) {
                //到达i位置的最小花费为，到达i-1位置的最小花费加上i-1位置的花费和到达i-2位置的最小花费加上i-2位置的花费的最小值
                dp[i] = Math.min(dp[i - 1] + cost[i - 1], dp[i - 2] + cost[i - 2]);
            }
            System.out.println(dp[n]);
        }
    }
}

//牛客:数组中两个字符串的最小距离
class Main5 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String str1 = in.next(), str2 = in.next();
        String[] strs = new String[n];
        for (int i = 0; i < n; i++) {
            strs[i] = in.next();
        }
        if (strs.length == 1) {
            System.out.println(-1);
            return;
        }
        int ret = Integer.MAX_VALUE;
        int l = Integer.MAX_VALUE, r = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            //遇到指定的字符串就记录它的位置，并计算两个字符串的最小距离
            if (str1.equals(strs[i])) {
                l = i;
                ret = r == Integer.MAX_VALUE ? ret : Math.min(ret,
                        Math.abs(l - r));
            } else if(str2.equals(strs[i])){
                r = i;
                ret = l == Integer.MAX_VALUE ? ret : Math.min(ret,
                        Math.abs(l - r));
            }
        }
        System.out.println(ret == Integer.MAX_VALUE ? -1 : ret);
    }
}